Deploying Linux binaries

(this page is obsolete, since deployment is now a built-in feature of recent CHICKEN versions)

If you want to deploy an application in binary form which uses many extensions ("eggs"), fiddling with compilation options can get quite involved and static linking might not always be practical.

An alternative approach is to deploy a sort of "bundle": a directory containing all required binaries, libraries and extensions. On Linux system we can change the paths where the dynamic linker should search for libraries via the LD_LIBRARY_PATH environment variable. Extensions are loaded by the CHICKEN runtime system from the so-called repository, which can be set through the CHICKEN_REPOSITORY environment variable.

So, to run a program inside a bundle, we have to set those two variables to the bundle directory and invoke the actual executable, for example in a start-script. There is one more problem, though: how can be call the startup script from an arbitrary location, or through a symbolic link (for example in /usr/local/bin)? We have to find out the full path to the bundle-directory. Linux provides the /proc directory, where we can resolve the exe link to obtain the absolute path of a running executable. This only works for binaries, not shell scripts, so we require a little startup program that fetches its location from the /proc directory and invokes the actual program to set LD_IBRARY_PATH and CHICKEN_REPOSITORY and calls our real program. The source code for the "runner" program can be found here.

So, what do we have to place into the bundle?

Finally wrap up the directory into a tarball and distribute it. Starting the runner will execute your program with the necessary settings. Installation requires merely to copy the bundle into a safe location and (if needed) creating a symbolic link in your path to the runner program.

Note: Solaris and *BSD have /proc filesystems too; it may require some work to adapt the "runner" program to them, as I don't know the details. --John Cowan

Solaris does have /proc/$$/object/a.out entries, but they are a weird kind of hardlinks. I don't see a way to figure out your real path via the proc filesystem on Solaris. --Thomas Chust

Note: You can always figure out your executable path in the classical way without relying on too much system support: Check if your zeroth command line argument contains a slash, if yes, prepend './' unless the slash is the first character, if no, try to prepend each PATH entry and check for executability, finally expand to full real path. I have written something like this before, so here goes an adapted version: http://www.chust.org/blob/chicken-stub.tar.gz --Thomas Chust

For Linux systems, patchelf may also be of interest.